import scala.beans.BeanProperty

// 主构造器直接在类名后面定义
class Person() {

  private var privateAge = 0
  @BeanProperty var name: String = _  // 将自动生成4个方法: scala的getter/setter 和 java的getter/setter

  def age = privateAge  // getter
  def age_= (newValue: Int) = {  // setter
    if (newValue > privateAge) privateAge = newValue
  }

  // 辅助构造器(名字为this)
  def this(name: String) {
    this()
    this.name = name
  }

  def this(name: String, age: Int) {
    this(name)
    this.age = age
  }

}
